package com.tyj.movie.controller;

import com.tyj.movie.entity.Movie;
import com.tyj.movie.service.MovieService;
import com.tyj.movie.vo.MainPageMovieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * 日期: 2021/7/6 14:50
 * 作者: 谭友杰
 * 类说明:
 */
@Controller
public class IndexController {

    @Autowired
    MovieService movieService;

    @RequestMapping({"/","index.html"})
    public ModelAndView indexPage(){
        ModelAndView modelAndView=new ModelAndView();
        MainPageMovieVo mainPageMovieVo=new MainPageMovieVo();

        //获取热映电影
        HashMap<String,Object> hashMap1= movieService.queryHotShowMovie();
        mainPageMovieVo.setHotShowMovie(hashMap1);

        //获取即将上映电影
        HashMap<String,Object> hashMap2= movieService.queryComingMovies();
        mainPageMovieVo.setComingMovieMovie(hashMap2);

        //获取热播电影
        List<Movie> hotMovies= movieService.queryHotMovies();
        mainPageMovieVo.setHotMovie(hotMovies);
        modelAndView.addObject("mainPageMovieVo",mainPageMovieVo);
        modelAndView.setViewName("index");

        return modelAndView;
    }
}
